home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7223 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: news.deltanet.com!usenet
  2. From: Robert Taylor <btaylor@deltanet.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Is there a standard for * and & placement style?
  5. Date: Wed, 21 Feb 1996 21:26:14 -0800
  6. Organization: Delta Internet Services, Anaheim, CA
  7. Message-ID: <312BFE76.A9@deltanet.com>
  8. References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com>
  9.             <4gckd5$bc7@clarknet.clark.net> <egpwb896e6.fsf@vipe.ii.uib.no> <312B5F0F.CFE@trpo4.tr.unisys.com>
  10. NNTP-Posting-Host: ana0023.deltanet.com
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=us-ascii
  13. Content-Transfer-Encoding: 7bit
  14. X-Mailer: Mozilla 2.0 (Win95; I)
  15.  
  16. Benjamin Romer wrote:
  17. > Ketil Z Malde wrote:
  18. > >
  19. > > Discussing
  20. > >
  21. > >         int *ip;
  22. > > vs.     int* ip;
  23. > >
  24. > > one might also observe that "*ip" is, in fact, an int, just as much as
  25. > > "ip" is an int*.  Just my two *.
  26. > >
  27. > > -kzm
  28. > >
  29. > Actually there has been a great deal of argument about which is considered
  30. > "correct", even though both work.
  31. > IMHO, the first method (int *ip) is safer for beginners, who might expect
  32. > int* a, b, c;
  33. > To define three pointers, while it in fact only defines one. This belief is
  34. > further reinforced in a beginner's view by the use of * in typecasting,
  35. > e.g. you must write (int*)ptrToAChar to get a pointer; if you write
  36. > (int)*ptrToAChar you actually get an int. (I know you don't have to typecast
  37. > char to int, it's only an example.) If you only define one variable per
  38. > statement, though, it looks and works just fine; personally, I'd write
  39. > int *a, *b, *c;
  40. > But that may just be stubbornness (and the fact that I've been using
  41. > that format since college). Some would even go so far as to insist on
  42. > using a typedef for pointers:
  43. > typedef int * ptrInt;
  44. > ptrInt ip, a, b, c;
  45. > This may be the safest way to do it but personally I think its a waste
  46. > of typing.
  47. > This is all merely opinion, though, and it really doesn't matter what you
  48. > use as long as it compiles and your meaning is clear.
  49. > $0.02
  50. > Freely yours,
  51. > Ben Romer
  52. > Software Engineer
  53. > Unisys Corporation
  54. > #include <stddisclaim.h>
  55.  
  56. I am one who would insist on a typedef...
  57. typedef int FAR * LPINT;
  58.  
  59. LPINT lpInteger;
  60.  
  61. I would also insist on Hungarian notation ;)
  62.  
  63. $0.0025
  64.  
  65. -- Bob T.
  66.